package top.bfylu.command.undo;

/**
 * 包名: top.bfylu.command.undo
 * 创建时间: 2022/2/7
 *
 * @author bfy
 * @version 1.0.0
 * <p>
 * 描述:
 * @Email bfyjian@gmail.com
 **/
public class RemoteLoader {

    public static void main(String[] args) {

        RemoteControlWithUndo remoteControl = new RemoteControlWithUndo();

        // 创建一个电灯对象和新支持undo()功能的命令
        Light livingRoomLight = new Light("Living Room");

        LightOnCommand livingRoomLightOn = new LightOnCommand(livingRoomLight);
        LightOffCommand livingRoomLightOff = new LightOffCommand(livingRoomLight);

        //将电灯命令设置到遥控器的0号插槽。
        remoteControl.setCommand(0, livingRoomLightOn, livingRoomLightOff);

        /**
         * 打开电灯，关闭电灯，然后撤销
         */
        remoteControl.onButtonWasPushed(0);
        remoteControl.offButtonWasPushed(0);
        System.out.println(remoteControl);
        remoteControl.undoButtonWasPushed();

        /**
         * 关闭电灯，打开电灯，然后撤销
         */
        remoteControl.offButtonWasPushed(0);
        remoteControl.onButtonWasPushed(0);
        System.out.println(remoteControl);
        remoteControl.undoButtonWasPushed();
    }


}
